package org.grow.erp.controller;

import org.grow.common.dto.EnumDto;
import org.grow.erp.entity.AuditState;
import org.grow.erp.entity.Department;
import org.grow.erp.entity.OperateState;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: xwg
 * @CreateDate: 2022/2/20
 */

@RestController
public class CommonController {
    @GetMapping("/operateStates")
    public List<EnumDto> operateStates() {
        return Arrays.stream(OperateState.values())
                .map(x -> new EnumDto(
                        x.ordinal(),
                        x.name(),
                        x.getText()))
                .collect(Collectors.toList());
    }

    @GetMapping("/auditStates")
    public List<EnumDto> auditStates() {
        return Arrays.stream(AuditState.values())
                .map(x -> new EnumDto(
                        x.ordinal(),
                        x.name(),
                        x.getText()))
                .collect(Collectors.toList());
    }

    @GetMapping("/departments")
    public List<EnumDto> departments() {
        return Arrays.stream(Department.values())
                .map(x -> new EnumDto(
                        x.ordinal(),
                        x.name(),
                        x.getText()))
                .collect(Collectors.toList());
    }
}
